/*
 * ComboLogin.java
 *
 * Created on 30 de junio de 2007, 05:10 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package everest3.usuarios;

import tablasYBasesdeDatos.S15WorkingBackspace;

import javax.swing.JComboBox;

/**
 *
 * @author Julian
 */
public class ComboLogin extends javax.swing.JComboBox
{
    
    /** Creates a new instance of ComboLogin */
    public ComboLogin() 
    {
        super();
        setEditable(true);
        new S15WorkingBackspace(this);
        establecerValores();
    }
    
    private void establecerValores()
    {
        tablasYBasesdeDatos.JDBCAdapter obj = new tablasYBasesdeDatos.JDBCAdapter(
                                                "jdbc:postgresql://localhost:5432/everest",
                                                 "org.postgresql.Driver","postgres","root");
        
        java.util.Vector resultadoBusqueda = obj.ConsultaIndividual("SELECT DISTINCT login FROM cuentasusuario ORDER BY login");
        
        if(resultadoBusqueda.size()==0)
            javax.swing.JOptionPane.showMessageDialog(null,
                                        "No se obtuvo nada",
                                        "Error",javax.swing.JOptionPane.WARNING_MESSAGE);
        
        else
        {
            for(int i=0; i<resultadoBusqueda.size();i++)
                this.addItem(resultadoBusqueda.elementAt(i));
        }
        
        try{
            obj.close();                       
        }
        
        catch(Exception e){System.out.println(e.getMessage());}
    }
}
